package com.ttg.web.dao.Impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttg.model.mapper.AdminRoleHideMapper;
import com.ttg.model.pojo.AdminRoleHide;
import com.ttg.web.dao.AdminRoleHideDao;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ZQ
 * @version 1.0
 * @Description
 * @date 2021/2/7 12:01
 */
@Service
public class AdminRoleHideDaoImpl extends ServiceImpl<AdminRoleHideMapper,AdminRoleHide> implements AdminRoleHideDao {



    @Override
    public Integer roleHideCount(Long roleId) {
        LambdaQueryWrapper<AdminRoleHide> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(AdminRoleHide::getArhRoleId,roleId);
        return count(wrapper);
    }

    @Override
    public boolean delete(Long roleId) {
        LambdaQueryWrapper<AdminRoleHide> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(AdminRoleHide::getArhRoleId,roleId);
        return remove(wrapper);
    }

    @Override
    public boolean saveOrUpdateAdmRoleHide(AdminRoleHide adminRoleHide) {
        return saveOrUpdate(adminRoleHide);
    }

    @Override
    public AdminRoleHide getArhByRoleId(Long roleId) {
        LambdaQueryWrapper<AdminRoleHide> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(AdminRoleHide::getArhRoleId,roleId);
        return getOne(wrapper);
    }

    @Override
    public List<AdminRoleHide> getArhByOrg(Long orgNo) {
        LambdaQueryWrapper<AdminRoleHide> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(AdminRoleHide::getArhRoleId).eq(AdminRoleHide::getArhRoleOrgNo,orgNo);
        return list(wrapper);
    }

}
